package com.sunb2b.web.controller;

import java.text.SimpleDateFormat;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sunb2b.entity.ViewCount;
import com.sunb2b.service.ViewCountService;
import com.sunb2b.util.JsonUtils;

@Controller
public class ViewCountController {
	@Inject
	private ViewCountService vcService;
	public static final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
	@RequestMapping(value="/vc")
	public @ResponseBody String view(ViewCount viewCount){
		ViewCount vc = vcService.view(viewCount);
		vc.setsLastDate(formatter.format(vc.getLastDate()));
		return JsonUtils.bean2json(vc);
	}
}
